<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=7">
		<title>完整demo</title>
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
		<script type="text/javascript" charset="utf-8" src="/editor/editor_config.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/editor.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/core/browser.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/core/utils.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/core/EventBase.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/core/dom/dtd.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/core/dom/domUtils.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/core/dom/Range.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/core/dom/Selection.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/core/Editor.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/core/ajax.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/core/filterword.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/inserthtml.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/autotypeset.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/autosubmit.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/background.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/image.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/justify.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/font.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/link.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/map.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/iframe.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/scrawl.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/removeformat.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/blockquote.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/convertcase.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/indent.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/print.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/preview.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/spechars.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/emotion.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/selectall.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/paragraph.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/directionality.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/horizontal.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/time.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/rowspacing.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/lineheight.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/cleardoc.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/anchor.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/delete.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/wordcount.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/pagebreak.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/wordimage.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/undo.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/paste.js"></script>       
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/list.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/source.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/shortcutkeys.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/enterkey.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/keystrokes.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/fiximgclick.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/autolink.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/autoheight.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/autofloat.js"></script> 
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/highlightcode.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/serialize.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/video.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/table.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/contextmenu.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/basestyle.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/elementpath.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/formatmatch.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/searchreplace.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/customstyle.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/catchremoteimage.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/snapscreen.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/attachment.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/webapp.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/template.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/plugins/music.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/ui.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/uiutils.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/uibase.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/separator.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/mask.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/popup.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/colorpicker.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/tablepicker.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/stateful.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/button.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/splitbutton.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/colorbutton.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/tablebutton.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/autotypesetpicker.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/autotypesetbutton.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/toolbar.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/menu.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/combox.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/dialog.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/menubutton.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/editorui.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/editor.js"></script>
		<script type="text/javascript" src="http://127.0.0.1:8080/editor/ui/multiMenu.js"></script>
		<style type="text/css">
			.clear {
				clear: both;
			}
		</style>
	</head>
	<body>
		<div>
			<script id="editor" type="text/plain" style="width:1076px;">这里可以书写，编辑器的初始内容</script>
		</div>
		<div class="clear"></div>
		<div id="btns">
			<div>
				<input type="button" value="获得整个html的内容" onclick="getAllHtml()">
				<input type="button" value="获得内容" onclick="getContent()">
				<input type="button" value="写入内容" onclick="setContent()">
				<input type="button" value="获得纯文本" onclick="getContentTxt()">
				<input type="button" value="获得带格式的纯文本" onclick="getPlainTxt()">
				<input type="button" value="判断是否有内容" onclick="hasContent()">
				<input type="button" value="使编辑器获得焦点" onclick="setFocus()">
			</div>
			<div>
				<input type="button" value="获得当前选中的文本" onclick="getText()" />
				<input type="button" value="删除编辑器" onclick="deleteEditor()" />
				<input id="enable" type="button" value="可以编辑" onclick="setEnabled()" />
				<input type="button" value="不可编辑" onclick="setDisabled()" />
				<input type="button" value="隐藏编辑器"
					onclick=" UE.getEditor('editor').setHide()" />
				<input type="button" value="显示编辑器"
					onclick=" UE.getEditor('editor').setShow()" />
			</div>

		</div>
		<div>
			<input type="button" value="创建编辑器" onclick="createEditor()" />
			<input type="button" value="删除编辑器" onclick="deleteEditor()" />
		</div>
	</body>
	<script type="text/javascript">

   //实例化编辑器
    UE.getEditor('editor');
    function createEditor(){
        enableBtn();
        UE.getEditor('editor')
    }
    function getAllHtml() {
        alert( UE.getEditor('editor').getAllHtml() )
    }
    function getContent() {
        var arr = [];
        arr.push( "使用editor.getContent()方法可以获得编辑器的内容" );
        arr.push( "内容为：" );
        arr.push(  UE.getEditor('editor').getContent() );
        alert( arr.join( "\n" ) );
    }
    function getPlainTxt() {
        var arr = [];
        arr.push( "使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容" );
        arr.push( "内容为：" );
        arr.push(  UE.getEditor('editor').getPlainTxt() );
        alert( arr.join( '\n' ) )
    }
    function setContent() {
        var arr = [];
        arr.push( "使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容" );
        UE.getEditor('editor').setContent( '欢迎使用ueditor' );
        alert( arr.join( "\n" ) );
    }
    function setDisabled() {
        UE.getEditor('editor').setDisabled( 'fullscreen' );
        disableBtn( "enable" );
    }

    function setEnabled() {
        UE.getEditor('editor').setEnabled();
        enableBtn();
    }

    function getText() {
        //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
        var range =  UE.getEditor('editor').selection.getRange();
        range.select();
        var txt =  UE.getEditor('editor').selection.getText();
        alert( txt )
    }

    function getContentTxt() {
        var arr = [];
        arr.push( "使用editor.getContentTxt()方法可以获得编辑器的纯文本内容" );
        arr.push( "编辑器的纯文本内容为：" );
        arr.push(  UE.getEditor('editor').getContentTxt() );
        alert( arr.join( "\n" ) );
    }
    function hasContent() {
        var arr = [];
        arr.push( "使用editor.hasContents()方法判断编辑器里是否有内容" );
        arr.push( "判断结果为：" );
        arr.push(  UE.getEditor('editor').hasContents() );
        alert( arr.join( "\n" ) );
    }
    function setFocus() {
        UE.getEditor('editor').focus();
    }
    function deleteEditor() {
        disableBtn();
        UE.getEditor('editor').destroy();
    }
    function disableBtn( str ) {
        var div = document.getElementById( 'btns' );
        var btns = domUtils.getElementsByTagName( div, "input" );
        for ( var i = 0, btn; btn = btns[i++]; ) {
            if ( btn.id == str ) {
                domUtils.removeAttributes( btn, ["disabled"] );
            } else {
                btn.setAttribute( "disabled", "true" );
            }
        }
    }
    function enableBtn() {
        var div = document.getElementById( 'btns' );
        var btns = domUtils.getElementsByTagName( div, "input" );
        for ( var i = 0, btn; btn = btns[i++]; ) {
            domUtils.removeAttributes( btn, ["disabled"] );
        }
    }
</script>
</html>